<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <link rel="stylesheet" type="text/css" href="./css/login.css"/>
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css">
    <script>
        //用于判空
        function handlerBlur(element){
            var content = element.value;
            var msg = element.parentElement.lastElementChild;
            if(content==""){
                msg.innerHTML="*不能为空";
                msg.style.display="inline";
                element.style.border="1px solid #fe7300";
                if(element.getAttribute("name")=="emailCode"){
                    element.style.borderRight="0";
                }
            }
        }
        //获得焦点事件
        function handlerFocus(element){
            var msg = element.parentElement.lastElementChild;
            msg.style.display="none";
            element.style.border="1px solid lightgrey";
            if(element.getAttribute("name")=="emailCode"){
                element.style.borderRight="0";
            }
        }
    </script>
</head>
<body>
<main>
    <div class="right-card">
        <form action="/doLogin"method="post" class="login">
            <div class="top">
                <h1 class="title">WeStudy</h1>
            </div>
            <p>
                <span class="icon"><i class="fa fa-user"></i></span>
                <input th:value="${username}" type="text" onblur="handlerBlur(this)" onfocus="handlerFocus(this)" name="username" placeholder="手机号/邮箱" autocomplete="off">
                <span th:text="${errorMsg}" class="error-msg"></span>
            </p>
            <p>
                <span class="icon"><i class="fa fa-lock"></i></span>
                <input type="password" onblur="handlerBlur(this)" onfocus="handlerFocus(this)" name="password" placeholder="请输入密码" autocomplete="off">
                <span class="error-msg"></span>
            </p>
            <p><button type="submit">登录</button></p>
            <div class="other">
                <div class="signup"><a href="/signup">注册</a></div><a class="forget" href="javascript:;">忘记密码？</a>
            </div>
        </form>
    </div>
</main>
</body>
</html>